package com.cn.demo4.controller;

import com.alibaba.fastjson.JSONObject;
import com.cn.demo4.common.Tool;
import com.cn.demo4.entity.NavTypeEntity;
import com.cn.demo4.entity.NewsTypeEntity;
import com.cn.demo4.service.INewsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Controller
@RequestMapping("/admin/newsType")
public class NewsTypeController {
    @Autowired
    private INewsTypeService iNewsTypeService;
    @RequestMapping("/findAll")
    @ResponseBody
    public void findAll(HttpServletResponse resp, HttpServletRequest req) throws IOException {
        Tool.setEncoding(req,resp);
        List<NewsTypeEntity> list = iNewsTypeService.findAll();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list", list);
        resp.getWriter().println(jsonObject);
    }
}
